from random import randint
import json
# 生成10x10随机矩阵
rand_matrix=json.dumps([" ".join([str(randint(1,10)) for j in range(10)])+"\n" for i in range(10)])

with open(r'C:\Users\SiliconValley520\Desktop\matrix.txt','wt',encoding='utf-8') as matrix_file:
    matrix_file.write(rand_matrix)



